Skip to content

Keep emitting blocks at their own light level during propagation - #124

Open
notsocafe wants to merge 1 commit into
Red-Studio-Ragnarok:mainfrom
notsocafe:fix/lava-lighting
Open

notsocafe wants to merge 1 commit into
Red-Studio-Ragnarok:mainfrom
notsocafe:fix/lava-lighting

Conversation

@notsocafe

Copy link
Copy Markdown

Full disclosure : The fix was generated using automated tooling, but was manually reviewed and tested.

📝 Description

LightingEngine.spreadLightFromCursor pushes a value of (source light - opacity) to each neighbour that is brighter than it currently is. It never compares that value with the neighbour's own emission. A neighbour that emits light but is not itself scheduled for an update, such as lava at level 15, can therefore receive a propagated value lower than its emission and keep it.

Observed on a client connected to a remote server, in a fresh Nether lava lake: the lighting engine wrote lava blocks with values from 1 to 14, never 15, 2311 times in 25 seconds. The air directly above the lava stayed dark, which appeared as dark patches on the lava surface. The patches did not clear with F3+A, which rebuilds render sections but does not change stored light, so the stored values themselves were wrong.

The same scenario in singleplayer did not show the problem. The cause of this difference has not been identified; the fix does not depend on it.

The fix takes the maximum of the propagated value and the neighbour's own block light, computed with the same LightUtil helper the initial calculation already uses:

newLight = max(propagatedLight, ownLight)

ownLight is only used for block light. Sky light has no per-block emission in this calculation, so its value is unchanged.

Behaviour after the fix:

  • The diagnostic log no longer reports any lava block below 15 on the client.
  • The dark patches are gone in game, on the remote server.
  • A residual case remains: air directly above lava can settle at 13 instead of 14 when it is reached first from a lateral neighbour. It is one light level and was not visible in game. Correcting it would need propagation to pull from every neighbour, not only the one pushing, which is a larger change and is not part of this commit.

🎯 Goals

  • Fix multiplayer lighting issue in the Nether

❌ Non Goals

  • Alterate any other lighting calculation

🚦 Testing

Tested in the same conditions as original diagnosis : nothing changes in singleplayer, while multiplayer is fixed.

⏮️ Backwards Compatibility

N/A

📚 Related Issues & Documents

N.A

🖼️ Screenshots/Recordings

This is how a freshly generated Nether looks like in multiplayer :

2026-11-27_04 44 51

After the fix, it looks just like Vanilla.

📖 Added to documentation?

  • 📜 README.md
  • 📑 Documentation
  • 📓 Javadoc
  • 🍕 Comments
  • 🙅 No documentation needed

😄 [optional] What gif best describes this PR or how it makes you feel?

LightingEngine.spreadLightFromCursor pushes a value of (source light - opacity)
to each neighbour that is brighter than it currently is. It never compares
that value with the neighbour's own emission. A neighbour that emits light
but is not itself scheduled for an update, such as lava at level 15, can
therefore receive a propagated value lower than its emission and keep it.

Observed on a client connected to a remote server, in a fresh Nether lava
lake: the lighting engine wrote lava blocks with values from 1 to 14, never
15, 2311 times in 25 seconds. The air directly above the lava stayed dark,
which appeared as dark patches on the lava surface. The patches did not
clear with F3+A, which rebuilds render sections but does not change stored
light, so the stored values themselves were wrong.

The same scenario in singleplayer did not show the problem. The cause of
this difference has not been identified; the fix does not depend on it.

The fix takes the maximum of the propagated value and the neighbour's own
block light, computed with the same LightUtil helper the initial calculation
already uses:

    newLight = max(propagatedLight, ownLight)

ownLight is only used for block light. Sky light has no per-block emission
in this calculation, so its value is unchanged.

Behaviour after the fix:

- The diagnostic log no longer reports any lava block below 15 on the client.
- The dark patches are gone in game, on the remote server.
- A residual case remains: air directly above lava can settle at 13 instead of
  14 when it is reached first from a lateral neighbour. It is one light level
  and was not visible in game. Correcting it would need propagation to pull
  from every neighbour, not only the one pushing, which is a larger change and
  is not part of this commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant